package com.community.backend.service.impl;

import com.community.backend.mapper.RepairMapper;
import com.community.backend.pojo.Repair;
import com.community.backend.pojo.dto.RepairQueryDTO;
import com.community.backend.service.RepairService;
import com.community.backend.utils.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RepairServiceImpl implements RepairService {
    private final RepairMapper repairMapper;

    public RepairServiceImpl(RepairMapper repairMapper) {
        this.repairMapper = repairMapper;
    }

    @Override
    public PageResult pageQuery(RepairQueryDTO repairQueryDTO) {
        PageHelper.startPage(repairQueryDTO.getCurrentPage(),repairQueryDTO.getPageSize());
        Page<Repair> page = repairMapper.pageQuery(repairQueryDTO);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void save(Repair repair) {
        repairMapper.insert(repair);
    }

    @Override
    public void update(Repair repair) {
        repairMapper.update(repair);
    }

    @Override
    public void deleteById(Integer id) {
        repairMapper.deleteById(id);
    }

}
